package com.ecommerce.dal.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.ecommerce.dal.dao.ICompanyPhotoDAO;
import com.ecommerce.dal.entity.CompanyPhoto;
import com.ecommerce.dal.util.CustomHibernateDAOSupport;

@Repository("companyPhotoDAO")
public class CompanyPhotoDAO extends CustomHibernateDAOSupport implements
		ICompanyPhotoDAO {

	@Override
	public void save(CompanyPhoto companyPhoto) {
		getHibernateTemplate().save(companyPhoto);

	}

	@Override
	public void update(CompanyPhoto companyPhoto) {
		getHibernateTemplate().update(companyPhoto);

	}

	@Override
	public void delete(CompanyPhoto companyPhoto) {
		getHibernateTemplate().delete(companyPhoto);

	}

	@Override
	public List<CompanyPhoto> findByCompanyId(long companyId) {
		List list = getHibernateTemplate()
				.find("select companyPhoto from CompanyPhoto companyPhoto inner join companyPhoto.company company where company.companyId=?",
						companyId);
		return ((list != null && list.size()>0) ?  list : null) ;
	}

}
